import 'package:flutter/material.dart';
import 'package:HaiPower/l10n/app_localizations.dart';

class BasicDemo extends StatelessWidget {
  final TextStyle _testStyle = TextStyle(fontSize: 16.2);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(AppLocalizations.of(context)!.me)),
      body: TextDemo(),
    );
  }
}

class RichTextDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return RichText(
      text: TextSpan(
        text: "Mr Chang",
        style: TextStyle(
          color: Colors.black,
          fontSize: 34.0,
          fontStyle: FontStyle.italic,
          fontWeight: FontWeight.w100,
        ),
        children: [
          TextSpan(
            text: ".net",
            style: TextStyle(
              color: Colors.blue,
              fontSize: 20.0,
              fontStyle: FontStyle.italic,
              fontWeight: FontWeight.w100,
            ),
          ),
        ],
      ),
    );
  }
}

class TextDemo extends StatelessWidget {
  final TextStyle _testStyle = TextStyle(fontSize: 16.2);
  final String _author = "李白";
  final String _title = "将进酒";

  @override
  Widget build(BuildContext context) {
    return Text(
      "《$_author》--$_title\n君不见黄河之水天上来，奔流到海不复回。天生我材必有用，千金散尽还复来。",
      textAlign: TextAlign.center,
      textDirection: TextDirection.ltr,
      style: _testStyle,
      maxLines: 3,
      overflow: TextOverflow.ellipsis,
    );
  }
}
